import store from '@/store'
import Vue from 'vue'

export function hasPermission(permission) {
  const myPermissions = store.getters.permissionList
  return myPermissions.indexOf(permission) > -1
}
export function buttonList(permission) {
  const myPermissions = store.getters.permissionList
  return myPermissions.indexOf(permission) > -1
}
export function bomCoster(permission) {
  const myPermissions = store.getters.permissionList
  return myPermissions.indexOf(permission) > -1
}
export function orderPurchase(permission) {
  const myPermissions = store.getters.permissionList
  return myPermissions.indexOf(permission) > -1
}
export function statement(permission) {
  const myPermissions = store.getters.permissionList
  return myPermissions.indexOf(permission) > -1
}

Vue.prototype.button = buttonList
Vue.prototype.hasPerm = hasPermission
Vue.prototype.bomCost = bomCoster
Vue.prototype.orderPurchase = orderPurchase
Vue.prototype.statement = statement
// Vue.prototype.$img = 'http://14.29.79.10:8808' // 图片加前缀
Vue.prototype.flanguage = localStorage.getItem('lang') || 'zh'
/* 摩洛哥项目8868， 惠州杰希8878  */
// 杰希、摩洛哥、内销
const publicPath = location.pathname
if (publicPath.indexOf('jc-web') !== -1) { // 惠州杰希 8878
  Vue.prototype.allots = true
  Vue.prototype.allotnx = false
  Vue.prototype.$img = 'http://139.159.188.124:8808/jc'
  Vue.prototype.$conUrl = 'http://139.159.188.124:8808/jc'
} else if (publicPath.indexOf('jnk-web') !== -1) { // 摩洛哥海绵 jnk
  Vue.prototype.allots = false
  Vue.prototype.allotnx = true
  Vue.prototype.$img = 'http://182.160.0.111:8808/jnk'
  Vue.prototype.$url = 'http://182.160.0.111:8808'
  Vue.prototype.$conUrl = 'http://182.160.0.111:8808/jnk'
} else if (publicPath.indexOf('fa-web') !== -1) { // 惠州杰希外销
  Vue.prototype.$img = 'http://139.159.188.124:8808/fa'
  Vue.prototype.$conUrl = 'http://139.159.188.124:8808/fa'
} else if (publicPath.indexOf('mw-web') !== -1) { // 麦斯威尔
  Vue.prototype.$img = 'http://139.159.188.124:8808/mw'
  Vue.prototype.$conUrl = 'http://139.159.188.124:8808/mw'
} else if (publicPath.indexOf('ct-web') !== -1) { // 麦斯威尔
  Vue.prototype.$img = 'http://139.159.188.124:8808/ct'
  Vue.prototype.$conUrl = 'http://139.159.188.124:8808/ct'
} else if (publicPath.indexOf('mr-web') !== -1) { // 麦斯威尔
  Vue.prototype.$img = 'http://182.160.0.111:8808/mr'
  Vue.prototype.$conUrl = 'http://182.160.0.111:8808/mr'
} else { // 线下
  Vue.prototype.allots = true
  Vue.prototype.allotnx = false
  Vue.prototype.$img = 'http://139.159.188.124:8808/jc'
  Vue.prototype.$url = 'http://14.29.79.10:8878'
  Vue.prototype.$conUrl = 'http://139.159.188.124:8808/jc'
}
